<template>
  <div class="index">
    <!-- 顶部 -->
    <div class="top"><Admin></Admin></div>
    <!-- bottom -->
    <div class="bottom">
      <div class="left"><SideNav></SideNav></div>
      <div class="right">
        <div class="content">
          <el-scrollbar style="height: 100%;">
            <!-- 当前位置 -->
            <div class="current_position">
              <p class="breadcrumb">当前位置 :</p>
              <el-breadcrumb separator="/">
                <el-breadcrumb-item class="up">用户相关</el-breadcrumb-item>
                <el-breadcrumb-item class="up"><a @click="goTo('/UserList1')">用户列表</a></el-breadcrumb-item>
                <el-breadcrumb-item>用户信息</el-breadcrumb-item>
              </el-breadcrumb>
            </div>
            <!-- 用户信息 -->
            <div class="userinformation">
              <div class="title">用户信息</div>
              <div class="message">
                <p><span class="p">用户ID :</span><span>{{id}}</span></p>
                <p>
                  <span class="p">头像 :</span>
                  <img :src="userinformation.userImgUrl" alt="" class="img">
                </p>
                <p><span class="p">手机号码 :</span><span>{{userinformation.phoneNumber}}</span></p>
                <p><span class="p">微信账号 :</span><span v-if="userinformation.wechatNickname">{{userinformation.wechatNickname}}</span><span v-else="userinformation.phoneNumber">{{userinformation.phoneNumber}}</span></p>
                <p><span class="p">注册时间 :</span><span>{{userinformation.userCreateTime | dateForma('YYYY-MM-DD HH:mm:ss')}}</span></p>
                <p><span></span><span><el-button @click="saveMessage()">保存</el-button></span></p>
              </div>
            </div>
          </el-scrollbar>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  let moment = require("moment")
  import Admin from '@/components/Admin.vue'
  import SideNav from '@/components/SideNav.vue'
  export default {
    name: 'UserListDetail1',
    components:{
      Admin,
      SideNav
    },
    data () {
      return {
        id: '',//会员id
        userinformation:'',//会员信息
      }
    },
    mounted() {
      // 取到路由带过来的参数
      this.id = JSON.parse(JSON.stringify(this.$route.query.data.id));
      console.log(this.id);
      this.getUserListDetails();
    },
    // 时间格式过滤
    filters: {
      dateForma(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
        return moment(dataStr).format(pattern)
      }
    },
    methods: {
      // 路由
      goTo(path) {
        this.$router.push(path);
      },
      // 根据id查询会员详情
      getUserListDetails(){
        this.$axios.post(this.baseURL1+'admin/user/info',{
          "userId": this.id,
          "requestSource":"PC"
        }).then((res)=>{
          console.log(res,"根据id 查询用户详情");
          if(res.data.code==1){
            this.userinformation = res.data.data;
          }
        }).catch((err)=>{
          console.log('request fail', err);
        })
      },
      // 保存修改
      saveMessage(){},
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
  @import '@/assets/css/index.scss'; //这个分号一定要写，要不会报错
  @import '@/assets/css/user.scss'; //这个分号一定要写，要不会报错
  .p{
    font-weight: bold;
  }
  .img{
    vertical-align: middle;
    width: 80px;
    height: 80px;
    border-radius: 40px;
    overflow: hidden;
  }
</style>
